package com.gg.fruit.controlller;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.beans.factory.annotation.Autowired;

import com.gg.entity.Fruit;
import com.gg.fruit.service.FruitService;

import helpers.baseservlet.BaseServlet;

@WebServlet("/fruit/SearchByCategoryServlet")
public class SearchByCategoryServlet extends BaseServlet {
	@Autowired
	private  FruitService fruitService;
	@Override
	
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String cid=request.getParameter("cid");
		List<Fruit> fruits=fruitService.searchFruitsByCategory(cid);
		request.getSession().setAttribute("searchfruits", fruits);
		response.sendRedirect("/fruits/sel.jsp");
	}
	
}
